package com.ztesoft.huangfu.learning.springboot.springbootexception.controller;

import com.ztesoft.huangfu.learning.springboot.springbootexception.exception.MyException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Author: huangfu.daohui
 * Date: 2018/6/8
 * Time: 22:26
 * Version: 1.0
 * Description: http://blog.battcn.com/2018/06/01/springboot/v2-other-exception/
 **/
@RestController
public class ExceptionController {
    @GetMapping("/exception")
    public String test3(Integer num) {
        if (num == null) {
            throw new MyException(400, "num不能为空");
        }
        int i = 10 / num;
        return "result:" + i;
    }
}
